#!/usr/bin/perl
#index.cgi

require './netfilter-lib.pl';
&ReadParse();
&error_setup($text{'error_mesg'});


&header($text{'modtitle'}, "", "index", 0, 1,);

print "<form name=modform action=index.cgi method=post onsubmit='return onsubmit_form();'>\n";
&list_mtab();
print "<input type=hidden name=command>\n";

print "</form>\n";
&footer("/", $text{'index'});


print <<EOF;
<script>
function onsubmit_form()
{
    document.modform.mstart.disabled = true;
    document.modform.mstop.disabled = true;
    document.modform.mcreate.disabled = true;
    document.modform.mdelete.disabled = true;
}


function on_mcreate_click()
{
    document.modform.action = 'ruleadd.cgi';
    document.modform.command.value = 'ruleadd'; 
}

function on_mdelete_click(length, confirmdel, chooseone)
{
    var i;
    var find = 0;
    if(length < 2)
    {
          if(length < 1)
          {
              return false;
          }
          else
          {
              if(document.modform.ruleline.checked)
              {
                   find = 1;
              }
          }
    }
    else
    {
          for(i = 0; i < length; i++)
          {
              if(document.modform.ruleline[i].checked)
              {
                   find = 1;
              }

          }
    }
    if(find == 0)
    {
          alert(chooseone);
          return false;
    }
    if(!confirm(confirmdel))
    {
       return false;
    }    

    document.modform.command.value = 'delete';
    document.modform.action = 'delrule.cgi';
}

function on_mdeleteall_click(length, confirmdel)
{

    if(!confirm(confirmdel))
    {
       return false;
    }    

    document.modform.command.value = 'delall';
    document.modform.action = 'delrule.cgi';
}
</script>
EOF
